package top.superflow.flow.runtime.process

import top.superflow.lang.StringUtils

import scala.beans.BeanProperty

class StaticClassRouteExtProcess extends ExtProcess{


  override def getProcessType : ProcessType.Value = ProcessType.CONDITION

  @BeanProperty
  var condition : String = StringUtils.EMPTY

  override def getKey: String = {
    super.getKey + this.condition
  }

  override def setMetadata (m : Map[String, Any]): Unit = {
    this.metadata ++= m
  }

  override def execute(request : ProcessRequest, response : ProcessResponse) = {

    val originalProcess = this.getOriginalProcess

    val expectedParameters = request.getParameters

    val result = originalProcess.execute(expectedParameters)

    fillResponse(result, response)
  }

  override def fillResponse(result: Any, response: ProcessResponse): Unit = {
    response.setResponse(result)
  }

}